
#include "command.h"
#include "definitions.h"
#include "stringutil.h"

// Default constructor...
Command::Command( void ) { // public
	setLevel( 0 );
	setEnabled( false );
	setOmniset( false );
}

// Destructor...
Command::~Command( void ) { } // public

void Command::setName( const std::string &name ) { // public
	_name = name;
	return;
}

std::string Command::getName( void ) const { // public
	return _name;
}

void Command::setLevel( const unsigned& level ) { // public
	_level = level;
	return;
}

unsigned Command::getLevel( void ) const { // public
	return _level;
}

void Command::setEnabled( const bool& enabled ) { // public
	_flags = ( enabled ) ? ( COMMAND_ENABLED | _flags ) : ( (~COMMAND_ENABLED) & _flags );
	return;
}

bool Command::getEnabled( void ) const { // public
	return ( (_flags & COMMAND_ENABLED) == COMMAND_ENABLED );
}

void Command::setOmniset( const bool& omniset ) { // public
	_flags = ( omniset ) ? ( COMMAND_OMNISET | _flags ) : ( (~COMMAND_OMNISET) & _flags );
	return;
}

bool Command::getOmniset( void ) const { // public
	return ( (_flags & COMMAND_OMNISET) == COMMAND_OMNISET );
}

void Command::setTags( const std::string& tags ) { // public
	_tags = tags;
	return;
}

std::string Command::getTags( void ) const { // public
	return _tags;
}

void Command::setSyntax( const std::string& syntax ) { // public
	_syntax = syntax;
	return;
}

std::string Command::getSyntax( void ) const { // public
	return _syntax;
}

void Command::setHelp( const std::string& help ) { // public
	_help = help;
	return;
}

std::string Command::getHelp( void ) const { // public
	return _help;
}

// General methods...
void Command::addSyntax( const std::string& line ) { // public
	if ( !getSyntax().empty() )
		setSyntax( getSyntax() + "\n\r" );
	setSyntax( getSyntax() + line + "{x" );
	return;
}

void Command::addHelp( const std::string& line ) { // public
	if ( !getHelp().empty() )
		setHelp( getHelp() + "\n\r" );
	setHelp( getHelp() + line + "{x" );
	return;
}
